<!--
 * @Author: yishen@mdashen.com
 * @Date: 2021-05-17 22:06:05
 * @LastEditTime: 2021-05-17 23:11:29
 * @Description: 专栏列表
-->
<template>
  <div class="column-list">
    <div class="row">
      <div class="col-4 mb-4" v-for="column in ColumnList" :key="column.id">
        <div class="card h-100 shadow-sm">
          <div class="card-body text-center">
            <img
              class="rounded-circle border border-light w-25 my-3"
              :src="column.avatar"
              :alt="column.title"
            />
            <h5 class="card-title">{{ column.title }}</h5>
            <p class="card-text text-left">{{ column.description }}</p>
            <a href="#" class="btn btn-outline-primary">进入专栏</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue'
export interface ColumnProps {
  id: number
  title: string
  avatar?: string
  description: string
}
export default defineComponent({
  name: 'column-list',
  components: {},
  props: {
    list: {
      type: Array as PropType<ColumnProps[]>,
      required: true
    }
  },
  setup (props) {
    const ColumnList = computed(() => {
      return props.list.map(column => {
        if (!column.avatar) {
          column.avatar = require('@/assets/column.png')
        }
        return column
      })
    })
    return { ColumnList }
  }
})
</script>

<style lang="scss" scoped>
.column-list {
}
</style>
